package com.cskaoyan.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class C3p0Utils {

    // 数据库连接池
    static DataSource dataSource;

    static {
        dataSource = new ComboPooledDataSource();
    }

    // 获取连接
    public static Connection getConnection(){
        Connection connection = null;
        try {
            connection =  dataSource.getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return  connection;

    }
}
